<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="/static/css/createtable.css"/>
		<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
	</head>
	<body>
		<div class="searchtable">
			<table >
				<tr><td>ID</td><td><span id="newID"></span></td></tr>
				<tr><td>设备ID</td><td><span id="newdevice_id"></span></td></tr>
				<tr><td>广告牌名称</td><td><span id="newname"></span></td></tr>
				<tr><td>设备类型</td><td><span id="newdevice_type"></span></td></tr>
				<tr><td>供网方式</td><td><span id="newnetwork"></span></td></tr>
				<tr><td>wifi共享方式</td><td><span id="newwifi"></span></td></tr>
				<tr><td>广告位类型</td><td><span id="newtype"></span></td></tr>
				<tr><td>广告位通电情况</td><td><span id="newpower_state"></span></td></tr>
				<tr><td>外壳类型</td><td><span id="newshell_type"></span></td></tr>
			</table>
			<p id="go">跳转</p>
		</div>
		<div class="create">
			<table >
				<tr><td>设备ID</td><td><input type="" name="device_id" id="device_id" value="" /></td></tr>
				<tr><td>广告牌名称</td><td><input type="" name="name" id="name" value="" /></td></tr>
				<tr><td>设备类型</td>
					<td>
						<select name="device_type" id="device_type">
							<option >带摄像头</option>
							<option >不带摄像头</option>
						</select>
					</td>
				</tr>
				<tr><td>供网方式</td>
					<td>
						<select name="network" id="network">
							<option >联通物联网卡</option>
							<option >移动物联网卡</option>
							<option >电信手机卡</option>
						</select>
					</td>
				</tr>
				<tr><td>wifi共享方式</td>
					<td>
						<select name="wifi" id="wifi">
							<option >MI-FI</option>
							<option >手机共享热点</option>
						</select>
					</td>
				</tr>
				<tr><td>广告位类型</td>
					<td>
						<select name="type" id="type">
							<option >固定面立柱大牌</option>
							<option >三面翻立柱大牌</option>
							<option >候车亭灯箱</option>
							<option >地下停车场灯箱</option>
							<option >社区灯箱</option>
							<option >城市道路灯箱</option>
						</select>
					</td>
				</tr>
				<tr><td>广告位通电情况</td>
					<td>
						<select name="power_state" id="power_state">
							<option >24小时直流供电</option>
							<option >晚上通电4小时（19：00-22：00）</option>
							<option >太阳能蓄电池供电</option>
							<option >充电电池供电</option>
						</select>
					</td>
				</tr>
				<tr><td>外壳类型</td>
					<td>
						<select name="shell_type" id="shell_type">
							<option >大射灯外壳</option>
							<option >射灯外壳（方形）分体式</option>
							<option >圆柱状射灯外壳</option>
							<option >塑料外壳</option>
						</select>
					</td>
				</tr>
			</table>
			<p onclick="setInfo()">添加</p>
		</div>
	</body>
	<script>
		// var keyword=document.getElementById('keyword').value;
		// var search = function () {
		// 	$.ajax({
		// 		type: 'post',
		// 		data:{'keyword':keyword},
		// 		url: '/index/builder/get_device_id',
		// 		async:true
		// 	}).then(function(res){
		// 		console.log(res)
		// 		if(res.success){
					
		// 		}
		// 	})
	 //  	}
	 var searchtable = document.getElementsByClassName('searchtable')[0];
	 var newID = document.getElementById('newID');
	 		var newname = document.getElementById('newname');
		  	var newdevice_id = document.getElementById('newdevice_id');
		  	var newdevice_type = document.getElementById('newdevice_type');
		  	var newnetwork = document.getElementById('newnetwork');
		  	var newwifi = document.getElementById('newwifi');
		  	var newtype = document.getElementById('newtype');
		  	var newpower_state = document.getElementById('newpower_state');
		  	var newshell_type = document.getElementById('newshell_type');
		  	var go= document.getElementById('go');
	  	var setInfo = function () {
		  	var name = document.getElementById('name');
		  	var device_id = document.getElementById('device_id');
		  	var device_type = document.getElementById('device_type');
		  	var network = document.getElementById('network');
		  	var wifi = document.getElementById('wifi');
		  	var type = document.getElementById('type');
		  	var power_state = document.getElementById('power_state');
		  	var shell_type = document.getElementById('shell_type');
		  	console.log(name);
			$.ajax({
				type: 'post',
				data:{'name':name.value,'device_id':device_id.value,'device_type':device_type.selectedIndex,'network':network.selectedIndex,'wifi':wifi.selectedIndex,'type':type.selectedIndex,'power_state':power_state.selectedIndex,'shell_type':shell_type.selectedIndex},
				url: '/index/builder/set_bill_info',
				async:true
			}).then(function(res){
				if(res.success){
			    	searchtable.style.display = 'block';
					newID.innerText = res.data.id
					newname.innerText = name.value;
					newdevice_id.innerText = device_id.value;
					newdevice_type.innerText = device_type.value;
					newnetwork.innerText = network.value;
					newwifi.innerText = wifi.value;
					newtype.innerText = type.value;
					newpower_state.innerText = power_state.value;
					newshell_type.innerText = shell_type.value;
					go.onclick = function () {
						// alert(123)"{:url('builder/builders','','')}/id/"+id
						window.location.href="{:url('builder/builders','','')}/id/"+res.data.id
					} 
				}
			})
	  	}

	</script>
</html>
